export default class time {

  // 将秒转换为分钟
  secondConvertMinute(number) {
    let m = 0,
      s = 0;
    m = Math.floor(number / 60);
    s = number % 60;

    m += ''
    s += ''
    //     如果只有一位数 前面加0
    m = (m.length == 1) ? '0' + m : m
    s = (s.length == 1) ? '0' + s : s
    return m + ':' + s;
  }
  getStringData() {
    let date = new Date()
    let week = ["日", '一', '二', '三', '四', '五', '六']
    let month = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二']
    const dateStr = {}

    let monthStr = month[date.getMonth()]
    let day = date.getDate()
    let weekStr = "星期" + week[date.getDay()]

    dateStr.monthStr = monthStr + '月'
    dateStr.day = day
    dateStr.weekStr = weekStr

    return dateStr
  }
     mGetDate(){
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        var d = new Date(year, month, 0);
        return d.getDate();
    }
  getDateA(){
      var date = new Date();
      var seperator1 = "-";
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var strDate = date.getDate();
      if (month >= 1 && month <= 9) {
          month = "0" + month;
      }
      if (strDate >= 0 && strDate <= 9) {
          strDate = "0" + strDate;
      }
      var currentdate = year + seperator1 + month + seperator1 + strDate;
      return currentdate;
  }

  formatTime(s) {
    var t;
    if (s > -1) {
      var hour = Math.floor(s / 3600);
      var min = Math.floor(s / 60) % 60;
      var sec = s % 60;
      if (hour < 10) {
        t = '0' + hour + ":";
      } else {
        t = hour + ":";
      }

      if (min < 10) {
        t += "0";
      }
      t += min + ":";
      if (sec < 10) {
        t += "0";
      }
      t += sec.toFixed(0);
    }
    return t;
  }
}